$(document).ready(function () {

    var rv = new ResetValidator();

    $('#set-password-form').ajaxForm({
        beforeSubmit: function (formData, jqForm, options) {
            ;
            rv.hideAlert();
            if (rv.validatePassword($('#pass-tf').val()) == false) {
                return false;
            } else {
                return true;
            }
        },
        success: function (responseText, status, xhr, $form) {
            rv.showSuccess("密码已重置");
            setTimeout(function () {
                window.location.href = '/';
            }, 2000);
        },
        error: function () {
            rv.showAlert("出错了, 请稍后再试");
        }
    });

    $('#set-password').modal('show');
    $('#set-password').on('shown', function () {
        $('#pass-tf').focus();
    })

});